package com.chinatsp.onlineapp.ui.news;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Html;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.chinatsp.onlineapp.R;
import com.chinatsp.onlineapp.listener.DetailNewsListener;
import com.chinatsp.onlineapp.utils.Utils;



public class NewsDetailFragment extends Fragment{
	 View view;
	    String news_title;
	    String news_content;
	    DetailNewsListener refresh;

	    public void setRefresh(DetailNewsListener refresh) {
	        this.refresh = refresh;
	    }

	    @Override
	    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	        view=inflater.inflate(R.layout.fragment_news_detail,null);
	        Bundle bundle=getArguments();
	        if(bundle!=null){
	            news_title=bundle.getString("news_title");
	            news_content=bundle.getString("news_content");
	        }
	        TextView title= (TextView) view.findViewById(R.id.tv_fragment_title);
	        TextView content= (TextView) view.findViewById(R.id.tv_fragment_content);
	        title.setText(news_title);
	        content.setMovementMethod(ScrollingMovementMethod.getInstance());
	        content.setText(Html.fromHtml(Utils.getBlankNewsContent(news_content)));
	       view.findViewById(R.id.iv_refresh).setOnClickListener(new View.OnClickListener() {
	           @Override
	           public void onClick(View v) {
	               refresh.refresh();
	           }
	       });

	        return view;
	    }
	
}
